package com.hgx.flink.scala.demo

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.flink.streaming.api.scala._


object WordCount {

  def main(args: Array[String]): Unit = {

    val env = ExecutionEnvironment.getExecutionEnvironment

    val inputPath = "D:\\hgxProject\\flink-abc\\flink-scala\\src\\main\\resources\\hello.txt"

    val inputDataSet = env.readTextFile(inputPath)

    val resultSet = inputDataSet.flatMap(_.split(" "))
      .map((_, 1))
      .groupBy(0)
      .sum(1)

    // 输入到控制台
    resultSet.print()
  }
}